package com.dirox.confluence.labelmanagement.service;

import com.atlassian.confluence.core.service.ValidationError;
import com.atlassian.confluence.labels.Label;

import java.util.Map;


public interface LabelManagementService {
    /**
     * <p>getLabelCountInSpace method:<br/>
     * Used to count number of labels
     * which current users have EDIT permission on.<br/>
     * Affected on a specific space.</p>
     *
     * @param spaceKey
     *
     * @return map of Label objects and number of that labels
     *
     * @see LabelManagementService#getLabelsCountInSpace(String spaceKey)
     */
    Map<Label, Integer> getLabelsCountInSpace(String spaceKey);

    /**
     * <p>getLabelCountInAllSpaces method:<br/>
     * Used to count number of labels
     * which the current user have EDIT permission on.<br/>
     * Affect all spaces.</p>
     *
     * @return map of Label objects and number of that labels
     *
     * @see LabelManagementService#getLabelsCountInAllSpaces()
     */
    Map<Label, Integer> getLabelsCountInAllSpaces();

    /**
     * <p>renameLabeInSpace method:<br/>
     * Used to rename labels from all spaces.
     * Take old-label, new-label then rename old-label to new-label.<br/>
     * Affect all spaces.</p>
     *
     * @param fromLabelName
     * @param toLabelName
     *
     * @return number of affected entity contents.
     *
     * @see LabelManagementService#renameLabelInAllSpaces(String fromLabelName,
     *      String toLabelName)
     */
    long renameLabelInAllSpaces(String oldLabelName, String newLabelName);

    /**
     * <p>renameLabeInAllSpace method: used to rename labels in space.
     * Take spaceKey, old-label, new-label then rename old-label to new-label.
     * Affect only on that space.</p>
     *
     * @param SpaceKey
     * @param fromLabelName
     * @param toLabelName
     *
     * @return number of affected entity contents.
     *
     * @see LabelManagementService#renameLabelInSpace(String spaceKey,String
     *      fromLabelName, String toLabelName)
     */
    long renameLabelInSpace(String spaceKey, String oldLabelName,
        String newLabelName);

    /**
     * <p>mergeLabelInSpace method: used to merge label in space.<br/>
     * Take spaceKey, then find and merge all labels in that space.</p>
     *
     * @param spaceKey
     * @param fromLabelName
     * @param toLabelName
     *
     * @return affected entity contents.
     *
     * @see LabelManagementService#mergeLabelInSpace(String spaceKey,String
     *      fromLabelName, String toLabelName)
     */
    long mergeLabelInAllSpaces(String fromLabelName, String toLabelName);

    /**
     * <p>mergeLabelInSpace method: used to merge label in all spaces.<br/>
     * Take first and second label, then find those in all spaces
     * and merge all labels with those name.</p>
     *
     * @param fromLabelName
     * @param toLabelName
     *
     * @return number of affected contents.
     * @see LabelManagementService#renameLabelInAllSpaces(String fromLabelName,
     *      String toLabelName)
     */
    long mergeLabelInSpace(String spaceKey, String fromLabelName,
        String toLabelName);

    /**
     * <p>deleteLabelInAllSpace() method:<br/>
     * Used to deleting all labels with name input in all spaces.</p>
     *
     * @param labelName
     * @return number of affected contents
     *
     * @see LabelManagementService#deleteLabelInAllSpaces(String)
     */
    long deleteLabelInAllSpaces(String labelName);

    /**
     * <p>deleteLabelInSpace() method:<br/>
     * Used to deleting all labels with name input in specific space.</p>
     *
     * @param spaceKey
     * @param labelName
     *
     * @return number of affected contents
     *
     * @see LabelManagementService#deleteLabelInSpace(String,String)
     */
    long deleteLabelInSpace(String spaceKey, String labelName);

    /**
     * <p>getLabelValidationError() method:<br/>
     * Used to validate label's name.</p>
     *
     * @param labelName
     *
     * @return ValidationError
     *
     */
    ValidationError getLabelValidationError(String label);

    /**
     * <p>isExistLabel() method:<br/>
     * Used check whether that label is existed or not.</p>
     *
     * @param labelName
     *
     * @return boolean
     */
    boolean isExistLabel(String labelName);

    /**
     * <p>isExistLabelInSpace() method:<br/>
     * Used check whether that label is existed in space or not.<br/>
     * Affected in space.</p>
     *
     * @param labelName
     * @param spaceKey
     *
     * @return boolean
     */
    boolean isExistLabelInSpace(String spaceKey, String labelName);
}
